package com.bac.rentmap.ad.flat.user.view;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class ViewStatistics {
    @SuppressWarnings("unused")
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private Date date;

    @Persistent
    @Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
    private Integer count;

    @SuppressWarnings("unused")
    @Persistent
    private Key flatAd;

    public ViewStatistics(Key flatAd, Date date) {
        this.flatAd = flatAd;
        this.date = date;
    }

    public Integer getCount() {
        return count;
    }

    public void inc(int delta) {
        if (count == null)
            count = 0;
        count += delta;
    }

    public Date getDate() {
        return date;
    }
}
